<script setup>
import {
    User,
    SwitchButton,
    CaretBottom
} from '@element-plus/icons-vue'
import avatar from '@/assets/default.png'
import { ref } from 'vue'
const tableData = ref()
import { allCreateClassInfoService } from '@/api/teacherApi/allCreateClassInfoService.js'
import {findallStudentByClass,findallTAByClass} from '@/api/adminApi/allAdmin.js'
const getClassInfo = async () => {
    let result = await allCreateClassInfoService();
    //console.log(result)
    tableData.value = result.data;
}
getClassInfo();
import { useRouter } from 'vue-router';
import { useClassNameStore } from '@/stores/className.js'
import { useClassIDStore } from '@/stores/classID.js'
import {useStudentListStore} from '@/stores/studentList.js'
//import {useAssistantListStore } from '@/stores/assitantList.js'

const studentistStore=useStudentListStore()
const classIDstore = useClassIDStore();
const classNameStore = useClassNameStore();
const router = useRouter()
//const assitantStore =useAssistantListStore()
const manage = async (rowClass) => {
    let classID = rowClass.classID
    classIDstore.setClassID(classID)
    let className = rowClass.className
    classNameStore.setClassName(className)
    const res=await findallStudentByClass(classID)
    studentistStore.setStudentList(res.data)
    //const res2=await findallTAByClass(classID)
    //assitantStore.setAssistantList(res2.data)
    router.push('/teacherClassCreateMange');
}
</script>
<template>
    <el-main class="card-container">
        <el-card class="custom-card" v-for="(item, index) in tableData" :key="index">
            <template #header>
                <div class="card-header">
                    <span>{{ item.className }}</span>
                </div>
            </template>
            <div>课程：{{ item.courseName }}</div>
            <div>开课时间：{{ item.startTime }}</div>
            <el-button @click="manage(item)">进入</el-button>
        </el-card>
    </el-main>
</template>
<style lang="scss" scoped>
.layout-container {
    height: 100vh;
    .el-header {
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .el-dropdown__box {
            display: flex;
            align-items: center;

            .el-icon {
                color: #999;
                margin-left: 10px;
            }

            &:active,
            &:focus {
                outline: none;
            }
        }
    }

    .el-footer {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: #666;
    }

    .card-container {
        display: flex;
        flex-wrap: wrap;
        /* 允许子元素在需要时换行 */
        justify-content: flex-start;
        /* 子元素从容器起始位置开始排列 */
        gap: 40px;

        /* 调整间隔大小 */
        .custom-card {
            border-radius: 15px;
            /* 圆润的边角 */
            overflow: hidden;
            /* 防止内容溢出边框 */
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            /* 添加阴影效果 */
            width: 350px;
            height: 200px;
            /* 调整卡片宽度 */
        }
    }


}
</style>